package com.disruptor.sample._07advance.consumer;

import com.disruptor.sample._07advance.dto.Trade;
import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class TradeHandler implements EventHandler<Trade>, WorkHandler<Trade> {

  @Override
  public void onEvent(Trade event, long sequence, boolean endOfBatch) throws Exception {
    this.onEvent(event);
  }

  @Override
  public void onEvent(Trade event) throws Exception {
    event.setId(UUID.randomUUID().toString());
    log.info("{}", event.getId());
  }
}
